package com.clj.cloud.authorization_server.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;

import com.clj.cloud.common.core.entity.vo.Result;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@SuppressWarnings("serial")
@EqualsAndHashCode(callSuper = true)
@Data
@JsonSerialize(using = CustomOauthExceptionSerializer.class)
public class CustomOauthException extends OAuth2Exception{

	 private final Result result;
	 
	 CustomOauthException(OAuth2Exception oAuth2Exception) {
	        super(oAuth2Exception.getSummary(), oAuth2Exception);
	        this.result = Result.fail(AuthErrorType.valueOf(oAuth2Exception.getOAuth2ErrorCode().toUpperCase()), oAuth2Exception);
	    }
}
